package com.lmf.mock.starter.autoconfigure.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.view.RedirectView;

/**
 * Mock管理页面控制器
 */
@Controller
public class MockAdminController {

    /**
     * 管理页面首页
     */
    @GetMapping("${mock.admin-path:/mock/admin}")
    public RedirectView adminPage(HttpServletRequest request) {
        String contextPath = request.getContextPath(); // 如 /aaa-svr 或 空串
        if (contextPath == null) {
            contextPath = "";
        }
        return new RedirectView(contextPath + "/mockPage/index.html");
    }
}
